#ifndef _Commands_hpp_
#define _Commands_hpp_

#include <memory>

#include "OrderBook.hpp"

namespace FeedHandler
{
	// abstract command
	class Command
	{
	public:
		typedef std::auto_ptr<Command> Ptr;

		virtual ~Command() {}

		// executes command on the given order book
		virtual void execute(OrderBook & ob) = 0;

		// parses text representation of command
		virtual void parse(const std::string & command) = 0;

	protected:
		Order m_order;
	};

	class OrderCommand : public Command
	{
	public:
		virtual void parse(const std::string & command);

	protected:
		Order m_order;
	};

	// concrete commands (add, remove, modify)
	class CmdAddOrder : public OrderCommand
	{
	public:
		virtual void execute(OrderBook & ob);
	};

	class CmdRemoveOrder : public OrderCommand
	{
	public:
		virtual void execute(OrderBook & ob);
	};

	class CmdModifyOrder : public OrderCommand
	{
	public:
		virtual void execute(OrderBook & ob);
	};

	class CmdTrade : public Command
	{
	public:
		virtual void execute(OrderBook & ob);
		virtual void parse(const std::string & command);

	protected:
		Trade m_trade;
	};

	// command factory
	class CommandFactory
	{
	public:
		// I'd better to use boost::shared_ptr there
		// but in requirements there are no word about boost
		Command::Ptr create(const std::string & command);
	};
}

#endif //_Commands_hpp_
